package com.xliu.csopenproject.pim_server.service;

import com.xliu.csopenproject.pim_server.store.ImageStore;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

@Service
public class ImageService {

    private final ImageStore imageStore;

    public ImageService(ImageStore imageStore) {
        this.imageStore = imageStore;
    }

    public void upload(MultipartFile file) throws IOException {
        imageStore.save(file);
    }

    public InputStream download(String fileId) throws IOException {
        return imageStore.read(fileId);
    }
}
